package net.mzzo.rc.util;

import java.lang.reflect.Field;

public class GetResourceId {
	public int getId(String filename) {
		
		try {
			Class<?> c=Class.forName("net.mzzo.rc.R$drawable");
			Field[] fs=c.getDeclaredFields();
			
			for (int i = 0; i < fs.length; i++) {
				Field f;
				if(fs[i].getName().equals(filename)) 
				{
					try {
						f = c.getDeclaredField(fs[i].getName());
						return f.getInt(null);
						} catch (IllegalArgumentException e) {
							e.printStackTrace();
						} catch (IllegalAccessException e) {
							e.printStackTrace();
					} catch (NoSuchFieldException e) {
						e.printStackTrace();
					}
				}
			}
		} catch (SecurityException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}
}
